<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式存储系统设计与实现</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 30px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 8px;
            margin-top: -8px;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        .mermaid {
            background: white;
            border-radius: 8px;
            padding: 20px;
        }
        .feature-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 tracking-tight">
                    分布式存储系统
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90 font-light">
                    设计与实现的艺术
                </p>
                <div class="flex justify-center space-x-8 text-sm">
                    <div class="flex items-center">
                        <i class="fas fa-server mr-2"></i>
                        <span>高可用性</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-expand-arrows-alt mr-2"></i>
                        <span>可扩展性</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-shield-alt mr-2"></i>
                        <span>容错能力</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-16 px-6">
        <div class="max-w-4xl mx-auto">
            <div class="content-card rounded-2xl shadow-xl p-10">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">设</span>计和实现分布式存储方案是分布式系统领域中的一个关键挑战。分布式存储系统需要处理大量数据，并且能够在多个物理节点上存储和管理这些数据。其设计目标通常包括高可用性、高可靠性、可扩展性、性能优化、一致性保证以及容错能力。
                </p>
            </div>
        </div>
    </section>

    <!-- Core Concepts -->
    <section class="py-16 px-6">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold mb-12 text-gray-800">核心概念与目标</h2>
            <div class="grid md:grid-cols-2 lg:grid-cols-4 gap-6">
                <div class="content-card card-hover rounded-xl p-6 text-center">
                    <div class="text-4xl mb-4 feature-icon">
                        <i class="fas fa-database"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2 text-gray-800">数据可靠性</h3>
                    <p class="text-gray-600">确保数据在发生节点故障时依然可用，通过冗余和备份机制保障数据安全</p>
                </div>
                <div class="content-card card-hover rounded-xl p-6 text-center">
                    <div class="text-4xl mb-4 feature-icon">
                        <i class="fas fa-sync-alt"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2 text-gray-800">数据一致性</h3>
                    <p class="text-gray-600">确保在多个节点上的数据副本保持一致，避免数据不一致问题</p>
                </div>
                <div class="content-card card-hover rounded-xl p-6 text-center">
                    <div class="text-4xl mb-4 feature-icon">
                        <i class="fas fa-expand"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2 text-gray-800">系统可扩展性</h3>
                    <p class="text-gray-600">系统能够随着数据量的增加和节点数量的变化而灵活扩展</p>
                </div>
                <div class="content-card card-hover rounded-xl p-6 text-center">
                    <div class="text-4xl mb-4 feature-icon">
                        <i class="fas fa-tachometer-alt"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-2 text-gray-800">高性能</h3>
                    <p class="text-gray-600">提供快速的数据读写能力和低延迟，满足高并发访问需求</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Data Sharding -->
    <section class="py-16 px-6 bg-gray-50">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold mb-12 text-gray-800">数据分片与存储结构设计</h2>
            <div class="grid lg:grid-cols-2 gap-8">
                <div class="content-card rounded-xl p-8">
                    <h3 class="text-2xl font-semibold mb-6 text-gray-800">
                        <i class="fas fa-puzzle-piece mr-3 text-purple-600"></i>分片策略
                    </h3>
                    <div class="space-y-4">
                        <div class="border-l-4 border-purple-500 pl-4">
                            <h4 class="font-semibold text-lg text-gray-700">范围分片（Range Sharding）</h4>
                            <p class="text-gray-600 mt-1">根据数据的范围来划分片段，例如将用户ID为1-1000的数据放在一个片段中。适用于有顺序访问需求的数据，但可能导致热点问题。</p>
                        </div>
                        <div class="border-l-4 border-purple-500 pl-4">
                            <h4 class="font-semibold text-lg text-gray-700">哈希分片（Hash Sharding）</h4>
                            <p class="text-gray-600 mt-1">通过对数据的某个字段进行哈希计算，根据哈希值将数据分配到不同的片段。可以有效避免热点问题，但不利于范围查询。</p>
                        </div>
                        <div class="border-l-4 border-purple-500 pl-4">
                            <h4 class="font-semibold text-lg text-gray-700">目录分片（Directory-Based Sharding）</h4>
                            <p class="text-gray-600 mt-1">维护一个目录服务来记录数据和分片的映射关系。适合动态变化的分片场景，但增加了维护的复杂性。</p>
                        </div>
                    </div>
                </div>
                <div class="content-card rounded-xl p-8">
                    <h3 class="text-2xl font-semibold mb-6 text-gray-800">
                        <i class="fas fa-layer-group mr-3 text-purple-600"></i>存储结构选择
                    </h3>
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <i class="fas fa-key text-purple-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">键值存储</h4>
                                <p class="text-gray-600 text-sm">适用于简单的键值对存储场景，如Redis、DynamoDB</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-file-alt text-purple-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">文档存储</h4>
                                <p class="text-gray-600 text-sm">适用于存储结构化和半结构化数据，如MongoDB、Couchbase</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-columns text-purple-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">列存储</h4>
                                <p class="text-gray-600 text-sm">适用于需要高效读取大量列数据的场景，如Cassandra、HBase</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-folder-open text-purple-500 mt-1 mr-3"></i>
                            <div>
                                <h4 class="font-semibold text-gray-700">分布式文件系统</h4>
                                <p class="text-gray-600 text-sm">用于存储大文件和海量数据，如HDFS、Ceph</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- System Architecture Diagram -->
    <section class="py-16 px-6">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold mb-12 text-gray-800">系统架构概览</h2>
            <div class="content-card rounded-xl p-8">
                <div class="mermaid">
                    graph TB
                        subgraph "客户端层"
                            C1[应用客户端]
                            C2[API网关]
                        end
                        
                        subgraph "元数据管理层"
                            M1[元数据服务器]
                            M2[分片映射表]
                            M3[副本位置信息]
                        end
                        
                        subgraph "数据存储层"
                            subgraph "分片组1"
                                S1[主节点]
                                S2[副本节点1]
                                S3[副本节点2]
                            end
                            subgraph "分片组2"
                                S4[主节点]
                                S5[副本节点1]
                                S6[副本节点2]
                            end
                        end
                        
                        subgraph "监控与管理"
                            MO1[健康检查]
                            MO2[故障恢复]
                            MO3[负载均衡]
                        end
                        
                        C1 --> C2
                        C2 --> M1
                        M1 --> M2
                        M1 --> M3
                        M2 --> S1
                        M2 --> S4
                        S1 -.-> S2
                        S1 -.-> S3
                        S4 -.-> S5
                        S4 -.-> S6
                        MO1 --> S1
                        MO1 --> S4
                        MO2 --> M1
                        MO3 --> C2
                </div>
            </div>
        </div>
    </section>

    <!-- Replication and Consistency -->
    <section class="py-16 px-6 bg-gray-50">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold mb-12 text-gray-800">数据复制与一致性模型</h2>
            <div class="grid lg:grid-cols-3 gap-6">
                <div class="content-card rounded-xl p-6 card-hover">
                    <div class="text-3xl mb-4 text-purple-600">
                        <i class="fas fa-lock"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3 text-gray